package com.uc.sdk.handler;

import com.uc.sdk.ClientGroup;

import com.uc.sdk.TcpClient;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ChannelStatusHandler extends ChannelInboundHandlerAdapter {
    private static final Logger LOGGER = LoggerFactory.getLogger(ChannelStatusHandler.class);
    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        String key = ctx.channel().id().asLongText();
        LOGGER.info("{} disconnect,need reconnect",key);
        Thread.sleep(1);
        TcpClient client = ClientGroup.findClient(key);
        client.connect();
        super.channelInactive(ctx);
    }
}
